SlideShare a Scribd company logo
1 of 16
Choosing a Concurrency Model  Optimistic or Pessimistic with SQL Server  Vinod Kumar M Technology Evangelist – Microsoft www.ExtremeExperts.com 20 / 04 / 10
Why Study  Concurrency? ,[object Object],[object Object],[object Object]
Concurrency Models ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Transactions  in SQL Server  ,[object Object],[object Object]
Transaction Basics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Preventable   Phenomena ,[object Object],[object Object],[object Object],[object Object]
Lost Update ,[object Object],T2 T1 Time X=10 X=20 X=25 X=25 Read X  (10) Read X  (10) Compute X=X+10 (20) Compute X=X+15 (25) Write X Write X
Dirty Read ,[object Object],T2 T1 Time X=10 X=25 X=10 Compute X=X+15 (25) Read X  (25) Read X  (10) Write X Rollback Use value of X that was never committed to DB
Non-Repeatable Read ,[object Object],T2 T1 Time X=10 X=25 Write X Read X  (10) Read X  (10) Compute X=X+15 (25) Commit Read X  (25)
“ Phantom” Problem ,[object Object],[object Object],[object Object],T2 T1 Time Smith,4 Brewer,7 Select count (*)  where rank > 3 (2) Jones,6 Smith,4 Brewer,7 Select count (*)  where rank > 3 (3) Insert Jones,6
Isolation   Levels ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SQL   2008   Isolation   Levels Phenomena Allowed Isolation Levels Dirty Read Non-Repeatable Read Phantoms Update Conflict Concurrency Model READ UNCOMMITTED Yes Yes Yes No READ COMMITTED 1  Locking 2 Snapshot   No No Yes Yes Yes Yes No No Pessimistic Optimistic REPEATABLE READ No No Yes No Pessimistic SNAPSHOT No No No Yes  Optimistic SERIALIZABLE No No No No Pessimistic
Locking Decision Isolation level Scan type (Range,  Table, Probe) # of rows in scan # of rows/page Locking strategy (Table, Page, Row) Operation type  (scan, update) Current  Activity Lock hints sp_IndexOption Settings
Walk through ISOLATION Levels
Summary ,[object Object],[object Object],[object Object],[object Object],[object Object]
Q&A ,[object Object],[object Object],[object Object]

More Related Content

Similar to Choosing a concurrency model, optimistic or pessimistic

Database concurrency and transactions - Tal Olier
Database concurrency and transactions - Tal OlierDatabase concurrency and transactions - Tal Olier
Database concurrency and transactions - Tal Olier
sqlserver.co.il
 
Clean & Dirty Acceptance Tests with Cucumber & Watir
Clean & Dirty Acceptance Tests with Cucumber & WatirClean & Dirty Acceptance Tests with Cucumber & Watir
Clean & Dirty Acceptance Tests with Cucumber & Watir
Danny Smith
 
No More No Repro
No More No ReproNo More No Repro
No More No Repro
Anna Russo
 
Roy Osherove on Unit Testing Good Practices and Horrible Mistakes
Roy Osherove on Unit Testing Good Practices and Horrible MistakesRoy Osherove on Unit Testing Good Practices and Horrible Mistakes
Roy Osherove on Unit Testing Good Practices and Horrible Mistakes
Roy Osherove
 
TDD - survival guide
TDD - survival guide TDD - survival guide
TDD - survival guide
vitalipe
 

Similar to Choosing a concurrency model, optimistic or pessimistic (20)

Database concurrency and transactions - Tal Olier
Database concurrency and transactions - Tal OlierDatabase concurrency and transactions - Tal Olier
Database concurrency and transactions - Tal Olier
 
SQL Server Transaction Management
SQL Server Transaction ManagementSQL Server Transaction Management
SQL Server Transaction Management
 
Getting Started With Testing
Getting Started With TestingGetting Started With Testing
Getting Started With Testing
 
Clean & Dirty Acceptance Tests with Cucumber & Watir
Clean & Dirty Acceptance Tests with Cucumber & WatirClean & Dirty Acceptance Tests with Cucumber & Watir
Clean & Dirty Acceptance Tests with Cucumber & Watir
 
Fantastic Tests - The Crimes of Bad Test Design
Fantastic Tests - The Crimes of Bad Test DesignFantastic Tests - The Crimes of Bad Test Design
Fantastic Tests - The Crimes of Bad Test Design
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
 
Sql server infernals
Sql server infernalsSql server infernals
Sql server infernals
 
Shift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David LaulusaShift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David Laulusa
 
Tdd in android (mvp)
Tdd in android (mvp)Tdd in android (mvp)
Tdd in android (mvp)
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)
 
6 Traits of a Successful Test Automation Architecture
6 Traits of a Successful Test Automation Architecture6 Traits of a Successful Test Automation Architecture
6 Traits of a Successful Test Automation Architecture
 
How Not to be a Cranky DBA
How Not to be a Cranky DBAHow Not to be a Cranky DBA
How Not to be a Cranky DBA
 
Clean Unit Test Patterns
Clean Unit Test PatternsClean Unit Test Patterns
Clean Unit Test Patterns
 
Clean code
Clean codeClean code
Clean code
 
Acceptance Test Driven Development at StarWest 2014
Acceptance Test Driven Development at StarWest 2014Acceptance Test Driven Development at StarWest 2014
Acceptance Test Driven Development at StarWest 2014
 
No More No Repro
No More No ReproNo More No Repro
No More No Repro
 
AWS Summit Melbourne 2014 | The Path to Business Agility for Vodafone: How Am...
AWS Summit Melbourne 2014 | The Path to Business Agility for Vodafone: How Am...AWS Summit Melbourne 2014 | The Path to Business Agility for Vodafone: How Am...
AWS Summit Melbourne 2014 | The Path to Business Agility for Vodafone: How Am...
 
Roy Osherove on Unit Testing Good Practices and Horrible Mistakes
Roy Osherove on Unit Testing Good Practices and Horrible MistakesRoy Osherove on Unit Testing Good Practices and Horrible Mistakes
Roy Osherove on Unit Testing Good Practices and Horrible Mistakes
 
How not to be a cranky dba
How not to be a cranky dbaHow not to be a cranky dba
How not to be a cranky dba
 
TDD - survival guide
TDD - survival guide TDD - survival guide
TDD - survival guide
 

More from Vinod Kumar (6)

Backup beyond just a strategy with SQL Server
Backup beyond just a strategy with SQL ServerBackup beyond just a strategy with SQL Server
Backup beyond just a strategy with SQL Server
 
SQL Server Query Optimization, Execution and Debugging Query Performance
SQL Server Query Optimization, Execution and Debugging Query PerformanceSQL Server Query Optimization, Execution and Debugging Query Performance
SQL Server Query Optimization, Execution and Debugging Query Performance
 
Advanced t sql - querying and programming inside sql server
Advanced t sql - querying and programming inside sql serverAdvanced t sql - querying and programming inside sql server
Advanced t sql - querying and programming inside sql server
 
Sql Server Security
Sql Server SecuritySql Server Security
Sql Server Security
 
Windows Mobile 5.0 Data Access And Storage Webcast
Windows Mobile 5.0 Data Access And Storage WebcastWindows Mobile 5.0 Data Access And Storage Webcast
Windows Mobile 5.0 Data Access And Storage Webcast
 
Protecting Your Key Asset – Data Protection Best Practices V2.0 Final
Protecting Your Key Asset – Data Protection Best Practices V2.0   FinalProtecting Your Key Asset – Data Protection Best Practices V2.0   Final
Protecting Your Key Asset – Data Protection Best Practices V2.0 Final
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Choosing a concurrency model, optimistic or pessimistic

  • 1. Choosing a Concurrency Model Optimistic or Pessimistic with SQL Server Vinod Kumar M Technology Evangelist – Microsoft www.ExtremeExperts.com 20 / 04 / 10
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12. SQL 2008 Isolation Levels Phenomena Allowed Isolation Levels Dirty Read Non-Repeatable Read Phantoms Update Conflict Concurrency Model READ UNCOMMITTED Yes Yes Yes No READ COMMITTED 1 Locking 2 Snapshot No No Yes Yes Yes Yes No No Pessimistic Optimistic REPEATABLE READ No No Yes No Pessimistic SNAPSHOT No No No Yes Optimistic SERIALIZABLE No No No No Pessimistic
  • 13. Locking Decision Isolation level Scan type (Range, Table, Probe) # of rows in scan # of rows/page Locking strategy (Table, Page, Row) Operation type (scan, update) Current Activity Lock hints sp_IndexOption Settings
  • 15.
  • 16.